<template>
  <img :src="icon || src" :alt="title" :title="title" style="cursor: pointer" @click="handleClick" />
</template>

<script>
import { logout } from '../../views/login/utils.js';
import icon from './assets/nav_bt_back.png';

export default {
  name: 'quit',
  props: {
    icon: { default: icon },
    title: { default: '退出' },
    address: { default: undefined },
  },
  data() {
    return {
      src: this.icon,
    };
  },
  methods: {
    handleClick() {
      if (typeof this.$attrs.onOnClick === 'function') {
        this.$attrs.onOnClick();
        return;
      }
      if (this.address) {
        window.location.href = this.address;
        return;
      }
      logout(true);
    },
  },
};
</script>

<style scoped></style>
